home *** CD-ROM | disk | FTP | other *** search
- CH 7 − USING EXTRA INDICES
- ==========================
- The record data is stored in a file called Database inside the database’s
- application directory. The order of records within Database is determined
- purely by the order in which the records are entered. To access the records
- in a logical order we need one or more indices. Powerbase has no sorting
- facilities other than the ability to sort a validation table or, under
- certain circumstances, a report. All data ordering is achieved by the use
- of indices.
-
- The most important index is index 0. This is always called “PrimaryKey” and
- is created as part of the process of setting up a database (see 4.5). You
- will find the file PrimaryKey inside the database directory. Other,
- subsidiary, indices are stored in the database’s Indices directory* and all
- have an icon bearing an “I”. When a database is opened any indices in this
- directory will be loaded automatically. (Indices operate in memory − to
- achieve maximum speed − not from disc.) Changes to the database update the
- indices and closing the database (or quitting Powerbase itself) causes the
- updated indices to be written back to the disc.
-
- Note that the more indices you use the longer it takes to add and delete
- records or to make alterations to records which involve changing indices.
- The ideal situation is to have all fields indexed and, given a fast enough
- machine, a hard disc and a record structure with not very many fields, this
- may be feasible. Remember that fields which are repetitive − those which
- have only a few distinct values repeated throughout many records − do not
- index efficiently.
-
- 7.1 Indexing a field
- =====================
- Click MENU over the required field and choose Index field choice from the
- Field submenu. The Key structure window will appear with the tag of the
- field you clicked on in the first Key field(s) icon. You may use the “bump”
- icons or pop-up menus to bring the tags of the other fields into view if you
- wish to base the index on more than one field. Enter the data in exactly the
- same way as when creating the primary key index (see 4.5) and click on
- Create. If the field is already indexed you will be warned of this and asked
- if you wish to overwrite the existing index. When indexing is complete you
- will see that the descriptor of the indexed field has changed from black to
- dark blue.
-
- Clicking on the “key” buttons on the keypad (Shift F4 and Shift F5) causes
- the red highlighting which indicates the current key to move from one
- indexed field to another. When you have a subsidiary key selected as the
- current key it works just like the primary key as regards browsing,
- searching and printing.
-
- There is nothing to stop you indexing one field whilst an index based on
- another field is the currently-active one, thus producing what amount to a
- sort within a sort.
-
- One button which was greyed out when creating the primary key is the option
- switch Omit null keys. Although null primary keys aren’t allowed null
- subsidiary keys are and the default setting for this switch is therefore
- “off”. The field being indexed might in some cases be null most of the time
- and you want to index only the records in which it isn’t. If so, select the
- switch before clicking Create.
-
- 7.2 Automatic saving of indices
- ================================
- Indices are written to disc when you close a database or quit Powerbase but,
- as long as the database remains open, they are in memory and therefore could
- be lost if the power failed or someone switched off your computer.
- Occasional use of the keypad’s Force update button ensures that the disc
- copy of all indices is more or less up-to-date but you can automate the
- process if you wish. Choose Preferences from the icon-bar menu, make the
- appropriate selection from the Save indices section of the Preferences
- window and click on Accept. You may make Powerbase save the indices at
- regular intervals or simply warn you to do so.